package net.sx.minemodule.adapter;

import android.support.annotation.Nullable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import net.sx.minemodule.R;
import net.sx.minemodule.mvp.bean.MineRefundProgressBean;


import java.util.List;

public class MineRefundProgressAdapter extends BaseQuickAdapter<MineRefundProgressBean, BaseViewHolder> {
    private int dataSize;

    public MineRefundProgressAdapter(@Nullable List<MineRefundProgressBean> data) {
        super(R.layout.mine_item_refund_progress, data);
        dataSize = data.size();
    }

    @Override
    protected void convert(BaseViewHolder helper, MineRefundProgressBean item) {
        View vTop = helper.getView(R.id.v_line_top);
        View vBottom = helper.getView(R.id.v_line_bottom);
        View vLine = helper.getView(R.id.v_line);
        ImageView imgPoint = helper.getView(R.id.img_point);
        TextView tvInfo = helper.getView(R.id.tv_info);

        helper.setText(R.id.tv_date, "2019-06-21 12：20：22");


        if (dataSize == 1) {//如果是有一个item
            tvInfo.setTextColor(mContext.getResources().getColor(R.color.color_333333));
            vTop.setVisibility(View.VISIBLE);
            vBottom.setVisibility(View.GONE);
            vLine.setVisibility(View.GONE);
        } else if (helper.getLayoutPosition() == 0) { //如果是第一个item
            tvInfo.setTextColor(mContext.getResources().getColor(R.color.color_333333));
            vTop.setVisibility(View.GONE);
            vBottom.setVisibility(View.VISIBLE);
            vLine.setVisibility(View.VISIBLE);
        } else if (helper.getLayoutPosition() == dataSize - 1) { //如果是最后一个item
            tvInfo.setTextColor(mContext.getResources().getColor(R.color.color_666666));
            vTop.setVisibility(View.VISIBLE);
            vBottom.setVisibility(View.GONE);
            vLine.setVisibility(View.GONE);
        } else {
            tvInfo.setTextColor(mContext.getResources().getColor(R.color.color_333333));
            vTop.setVisibility(View.VISIBLE);
            vBottom.setVisibility(View.VISIBLE);
            vLine.setVisibility(View.VISIBLE);
        }

    }
}
